<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>
<jsp:include page="inc.jsp"></jsp:include>    
<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>数字教学教务信息管理平台</title> 
	
</head> 
<body>
    <div class="container">
        <div id="pf-hd" style="background: url(${ctx }/images/main/topbg.png);">
            <div class="pf-logo">
                <img src="${ctx }/images/main/main_logo.png" alt="logo">
            </div>
            
            
            


            <div class="pf-user">
                <div class="pf-user-photo">
                    <img style="width: 40px;height: 40px;
                    border-radius: 20px;" 
                    src="${ctx}/sys/showPhoto" alt="">
                </div>
                <h4 class="pf-user-name ellipsis">${eu.name }</h4>
                <i class="iconfont xiala">&#xe607;</i>

                <div class="pf-user-panel">
                    <ul class="pf-user-opt">
                        <li>
                            <a href="javascript:updateInfo()" >
                                <i class="iconfont">&#xe60d;</i>
                                <span class="pf-opt-name" >用户信息</span>
                            </a>
                        </li>
                        <li class="">
                            <a href="#" onclick="updatePwd()">
                                <i class="iconfont">&#xe634;</i>
                                <span class="pf-opt-name">修改密码</span>
                            </a>
                        </li>
                        <li class="pf-logout">
                            <a href="#" onclick="loginOut()">
                                <i class="iconfont">&#xe60e;</i>
                                <span class="pf-opt-name">退出</span>
                            </a>
                        </li>
                    </ul>
                </div>
            </div>

        </div>

        <div id="pf-bd">
            <div id="pf-sider">
                <h2 class="pf-model-name">
                    <span class="iconfont">&#xe64a;</span>
                    <span class="pf-name">菜单目录</span>
                    <span class="toggle-icon"></span>
                </h2>

                <ul class="sider-nav">
                     
                     
                 </ul> 
            </div>

            <div id="pf-page">
                <div class="easyui-tabs1" style="width:100%;height:100%;">
                  <div title="首页" style="padding:10px 5px 5px 10px;">
                    <iframe class="page-iframe" src="${ctx }/sys/index" frameborder="no"   border="no" height="100%" width="100%" scrolling="auto"></iframe>
                  </div>
                  
                </div>
            </div>
        </div>

        <div id="pf-ft">
            <div class="system-name">
              <i class="iconfont">&#xe6fe;</i>
              <span>数字教学教务信息管理平台&nbsp;v1.0</span>
            </div>
            <div class="copyright-name">
              <span>CopyRight&nbsp;2016&nbsp;&nbsp;entor.com&nbsp;版权所有</span>
              <i class="iconfont" >&#xe6ff;</i>
            </div>
        </div>
    </div>
	<input type="hidden" id="rid" value="${eu.roleId }"/>
    
    <script type="text/javascript">
    $(function(){
    	crateMenu();
    	$('.sider-nav li ul li').click(function(){
    		$('.sider-nav li ul li').removeClass('active');
    		$(this).addClass('active');
    		var title = $(this).find('a').html();
    		var src = $(this).attr('src');
    		addTabs(title,src);
    	});
    	
    });
    function crateMenu(){
    	var rid = $('#rid').val();
    	$.ajax({
    		async:false,
    		type:'post',
    		url:'${ctx}/role/getMenu/'+rid,
    		dataType:'json',
    		success:function(r){
    			r = $.parseJSON(r);
    			var str = '';
    			$.each(r,function(i,item){
    				var cur = 'current';
    				if(i>0){
    					cur = '';
    				}
    				str += '<li class="'+cur+'">'+
				                '<a href="javascript:;">'+
				                    '<span class="iconfont sider-nav-icon">&#xe620;</span>'+
				                    '<span class="sider-nav-title">'+item.name+'</span>'+
				                    '<i class="iconfont">&#xe642;</i>'+
				                '</a>'+
				                '<ul class="sider-nav-s">';
				                $.each(item.childrens,function(j,c){
				                	str+='<li src="${ctx}/'+c.src+'"><a href="#">'+c.name+'</a></li>';
				                });
				                
				                str+='</ul>'+
				             '</li>';
					             
    			});
				$('.sider-nav').html(str);
    		}
    	});
    }
    function updateInfo(){
    	$('#d1').dialog({
    		title:'个人信息',
    		width:500,
    		height:640,
    		modal:true,
    		content:'<iframe class="page-iframe" '
				+'src="${ctx}/user/updateInfo" frameborder="no" '
				+' border="no" height="100%" width="100%" '
				+' scrolling="auto"></iframe>'
    	});
    }
    function addTabs(title,src){
    	var tab = $('.easyui-tabs1');
		if(tab.tabs('exists',title)){
			tab.tabs('select',title);
		}else{
			//新增选项卡
			tab.tabs('add',{
				title:title,
				closable:true,
				selected:true,
				content:'<iframe class="page-iframe" '
				+'src="'+src+'" frameborder="no" '
				+' border="no" height="100%" width="100%" '
				+' scrolling="auto"></iframe>'
			});
		}
    	
    }
    
    $('.easyui-tabs1').tabs({
      tabHeight: 44,
      onSelect:function(title,index){
        var currentTab = $('.easyui-tabs1').tabs("getSelected");
        if(currentTab.find("iframe") && currentTab.find("iframe").size()){
            currentTab.find("iframe").attr("src",currentTab.find("iframe").attr("src"));
        }
      }
    })
    $(window).resize(function(){
          $('.tabs-panels').height($("#pf-page").height()-46);
          $('.panel-body').height($("#pf-page").height()-76)
    }).resize();

    var page = 0,
        pages = ($('.pf-nav').height() / 70) - 1;

    if(pages === 0){
      $('.pf-nav-prev,.pf-nav-next').hide();
    }
    $(document).on('click', '.pf-nav-prev,.pf-nav-next', function(){


      if($(this).hasClass('disabled')) return;
      if($(this).hasClass('pf-nav-next')){
        page++;
        $('.pf-nav').stop().animate({'margin-top': -70*page}, 200);
        if(page == pages){
          $(this).addClass('disabled');
          $('.pf-nav-prev').removeClass('disabled');
        }else{
          $('.pf-nav-prev').removeClass('disabled');
        }
        
      }else{
        page--;
        $('.pf-nav').stop().animate({'margin-top': -70*page}, 200);
        if(page == 0){
          $(this).addClass('disabled');
          $('.pf-nav-next').removeClass('disabled');
        }else{
          $('.pf-nav-next').removeClass('disabled');
        }
        
      }
    })

   
    function loginOut(){
    	$.messager.confirm('系统警告','真的要退出系统?',
    	function(r){
    		if(r){
    			var url = '${ctx}/user/loginOut';
    	    	submitData(url,null);
    	    	window.location.href='${ctx}/sys/login';
    		}
    	});
    	
    }
    
    function updatePwd(){
    	$('#d1').dialog({
    		width:430,
    		height:350,
    		modal:true,
    		title:'修改密码',
    		href:'${ctx}/user/updatePwd',
    		buttons:[{
    			text:'保存',
    			iconCls:'icon-save',
    			handler:function(){
    				var f = $('#dataForm');
    				var data = f.serialize();
    				var url = '${ctx}/user/toEditPwd';
    				var r = submitData(url,data);
    				alert(r.msg);
    				if(r.sus){
    					$('#d1').dialog('close');
    				}
    			}
    		},{
    			text:'取消',
    			iconCls:'icon-cancel',
    			handler:function(){
    				$('#d1').dialog('close');
    			}
    		}],
    	});
    }
    </script>
    <div id="d1"></div>
</body> 
</html>
